package lesson02;

import java.io.FileInputStream;
import java.io.IOException;

/**
 * 功能描述
 *
 * @author wileda
 * @date 2023/02/12  9:38
 */
public class Demo01_InputStream {
    public static void main(String[] args) throws IOException {
        //创建一个输入流，读取文件内容
        FileInputStream fileInputStream = new FileInputStream("D:\\temp\\test\\test.txt");
        //通过一个byte数组，来接受每次读取的内容，扩大缓冲区的容量
        byte[] bytes = new byte[1024];
        while(true){
            int len = fileInputStream.read(bytes);
            if(len == -1){
                break;
            }
            for (int i = 0; i < len; i++) {
                System.out.println(bytes[i]);
            }
        }
        fileInputStream.close();
    }

    public static void main1(String[] args) throws IOException {
        FileInputStream fileInputStream1 = new FileInputStream("D:\\temp\\test\\test.txt");

        while(true){
            int read = fileInputStream1.read();
            if(read == -1){
                break;
            }
            System.out.println(read);
        }
    }
}

